<?php
$http = new Swoole\Http\Server("0.0.0.0", 8811);
$http->set([
    'enable_static_handler' => true,
    'document_root' => '/data/swoole_mooc/data'
]);
$http->on('request', function ($request, $response) {
    $response->header("Content-Type", "text/html; charset=utf-8");

    $content = [
        'data:' => date('Ymd H:i:s'),
        'get:' => $request->get,
        'post:' => $request->post,
        'header:' => $request->header
    ];
    // swoole_async_writefile(__DIR__ . "/access.log", json_encode($content) . PHP_EOL,function ($filename) {
    //     //@todo 处理逻辑
    // },FILE_APPEND);

    $response->cookie('ahao','ahao-' . time(),time() + 1800);
    $response->end("<h1>获取信息：</h1>" . json_encode($request->get));
});
$http->start();